#pragma once
#include <QDebug>
#include "datafile.h"
#include "tabarray.h"

class AppCore : public QObject
{
	Q_OBJECT
public:
	explicit AppCore(QObject *parent = 0);
	inline void readBookmarks(QString fileName) { emit bookmarksGotten(data->read(fileName)); }
signals:
	void tabGotten(TabItem *tab);
	void tabCreated(TabItem *tab);
	void bookmarksGotten(QVector<BookmarkItem*> *bookmarks);
public slots:
	void saveTab(int index, BookmarkItem *bookmark) { array->changeTab(index, bookmark); }
	void getTab(unsigned index) { emit tabGotten(array->tabAt(index)); }
	inline void newTab(TabItem *tab) { emit tabCreated(array->newTab(tab)); }
	inline void deleteTab(int index) { array->deleteTab(index); }
private:
	DataFile *data;
	TabArray *array;
};
